Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Data typeDescriptionExample
StringUTF-8 encoded text string"Alice"
Integer32-bit signed integer (int32)25
Long64-bit signed integer (int64) for large valuesNumberLong(9999999999)
Double64-bit IEEE 754 floating-point number19.99
Decimal128128-bit high-precision decimalNumberDecimal("99.99")
BooleanLogical true / false valuetrue
ObjectId12-byte unique identifier, auto-generated for _id fieldsObjectId('69d2bdb643fd93140a3e2a90')
DateDate and time stored as milliseconds since Unix epochnew Date("2024-01-01")
ArrayOrdered list of values of any type["js", "db"]
ObjectEmbedded (nested) document{ "city": "Kyiv" }
NullRepresents the absence of a valuenull
BinaryRaw binary data (files, hashes)BinData(0, "base64==")
RegexRegular expression stored as a native BSON type/^abc/i
TimestampInternal MongoDB type used for replication (not for storing dates)Timestamp(1, 1)
MinKey / MaxKeySpecial values that compare lower / higher than any other BSON valueused in indexes
SymbolDeprecated string-like type – not recommended for useSymbol("name")
JavaScriptStores a JavaScript function or code snippet directly in a document. Historically used with $where queries – largely deprecated in modern MongoDB due to security concerns{ "$code": "function() { return this.age > 18; }" }